package org.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.*;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/ws").withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.setApplicationDestinationPrefixes("/app");
        registry.enableSimpleBroker("/topic");
    }
//@Override
//public void configureMessageBroker(MessageBrokerRegistry registry) {
//    registry.setApplicationDestinationPrefixes("/app");
//    // Use this for enabling a Full featured broker like RabbitMQ
//    registry.enableStompBrokerRelay("/topic")
//            .setRelayHost("localhost")
//            .setRelayPort(15672)
//            .setClientLogin("guest")
//            .setClientPasscode("guest");
//}

}
